(function () {
	'use strict';
	var global$7 = tinymce.util.Tools.resolve('tinymce.PluginManager');
	var unlinkSelection = function (editor) {
			var dom = editor.dom, selection = editor.selection;
			var bookmark = selection.getBookmark();
			var rng = selection.getRng().cloneRange();
			var startAnchorElm = dom.getParent(rng.startContainer, 'a[href]', editor.getBody());
			var endAnchorElm = dom.getParent(rng.endContainer, 'a[href]', editor.getBody());
			if (startAnchorElm) {
					rng.setStartBefore(startAnchorElm);
			}
			if (endAnchorElm) {
					rng.setEndAfter(endAnchorElm);
			}
			selection.setRng(rng);

			if (editor.selection.isCollapsed()) {
					var elm = editor.dom.getParent(editor.selection.getStart(), 'a');
					if (elm) {
							editor.dom.remove(elm, true);
					}
					return;
			}
			editor.formatter.remove('link');

			selection.moveToBookmark(bookmark);
	};
	var getHref = function (elm) {
			var href = elm.getAttribute('data-mce-href');
			return href ? href : elm.getAttribute('href');
	};
	var gotoLink = function (editor, a) {
			if (a) {
					var href = getHref(a);
					if (/^#/.test(href)) {
							var targetEl = editor.$(href);
							if (targetEl.length) {
									editor.selection.scrollIntoView(targetEl[0], true);
							}
					} else {
							open(a.href);
					}
			}
	};
	var getLink = function (editor, elm) {
			return editor.dom.getParent(elm, 'a[href]');
	};
	var getSelectedLink = function (editor) {
			return getLink(editor, editor.selection.getStart());
	};
	var gotoSelectedLink = function (editor) {
			return function () {
					gotoLink(editor, getSelectedLink(editor));
			};
	};
	var unlinkDomMutation = function (editor) {
			editor.undoManager.transact(function () {
					var node = editor.selection.getNode();
							unlinkSelection(editor);
							editor.focus();
			});
	};
	var setupMenuItems = function (editor) {
			editor.ui.registry.addMenuItem('addJcxm', {
					text: 'addJcxm',
					icon: 'new-tab',
					onAction: function (){
							var tdObject = editor.dom.getParent(editor.selection.getStart(), "td");
							editor.execCallback('addJcxmCallBack', editor,tdObject);
							editor.undoManager.add();
					}
			});
	};
	var setupContextMenu = function (editor) {
			editor.ui.registry.addContextMenu('addJcxm', {
					update: function (element) {
							var tdObject = editor.dom.getParent(editor.selection.getStart(), "td");
							if(!tdObject) return "";
							var tr = tdObject.closest("tr");
							if (!(tr.classList.contains("childTr"))) return ""
							return "addJcxm";
					}
			});
	};
	function Plugin () {
			global$7.add('addJcxm', function (editor) {
					setupMenuItems(editor);
					setupContextMenu(editor);
			});
	}

	Plugin();
}());